<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>运单管理</title>
    <link th:include="common/header::copy"/>
    <script type="text/javascript">

        function formatOp(val, row, index) {
            var str = '';
            if ($("#update").length > 0) {
                str += $.formatString('<a href="javascript:void(0)" class="role-easyui-linkbutton-edit"  onclick="editTransFun(\'{0}\');" >编辑</a>', index);
            }
            return str;
        }

        function search() {
            $("#dg").datagrid('load', {
                "lname": $("#s_lname").val(),
                "cname": $("#s_cname").val(),
                "vidcard": $("#s_vidcard").val()
            });
        }

        function resetValue() {
            $("#id").val("");
            $("#lname").val("");
            $("#cname").val("");
            $("#vidcard").val("");
            $("#tname").val("");
            $("#unitPrice").val("");
            $("#laps").val("");
            $("#dues").val("");
            $("#invoiceStatus").val("");
            $("#paymentStatus").val("");
            $("#leadername").val("");
            $("#drivername").val("");
            $("#trackname").val("");
        }

        function editTransFun(index) {
            $("#dg").datagrid('selectRow', index);
            var row = $("#dg").datagrid('getSelected');
            $("#dlg").dialog("open").dialog("setTitle", "修改角色信息");
            $("#fm").form("load", row);
        }

        function openAddDialog() {
            $("#dlg").dialog("open").dialog("setTitle", "添加运单信息");
        }

        function cellStyler(value) {
            if (value == true) {
                return '<span style="color: greenyellow">已经结清</span>';
            } else {
                return '<span style="color: red">未结清</span>';
            }
        }

    </script>
</head>
<body style="margin: 1px">
<shiro:hasPermission name="pro:transport:save">
    <input type="hidden" id="update"/>
</shiro:hasPermission>
<table id="dg" title="运单信息" class="easyui-datagrid"
       fitColumns="true" pagination="true" rownumbers="true" singleSelect="true"
       url="/pro/transport/list" fit="true" toolbar="#tb" method="post" striped="true">
    <thead>
    <th field="id" width="20" align="center" hidden="true">编号</th>
    <th field="lname" width="100" align="center">队长名字</th>
    <th field="cname" width="80" align="center">司机名字</th>
    <th field="vidcard" width="100" align="center">车牌号</th>
    <th field="tname" width="100" align="center">线路名</th>
    <th field="unitPrice" width="100" align="center">单趟价格</th>
    <th field="laps" width="50" align="center">趟数</th>
    <th field="dues" width="80" align="center">应付款</th>
    <th field="invoiceStatus" width="100" align="center" formatter="cellStyler">发票状态</th>
    <th field="paymentStatus" width="100" align="center" formatter="cellStyler">支付状态</th>
    <th field="op" width="100" align="center" formatter="formatOp">操作</th>
    </thead>
</table>

<div id="tb">
    <div shiro:hasPermission="pro:transport:save" style="display: inline-block;">
        <a href="javascript:openAddDialog();" class="easyui-linkbutton" iconCls="icon-add" plain="true">添加</a>
        <a href="javascript:search();" class="easyui-linkbutton" data-options="plain:true"
           onclick="$('#dg').datagrid('toExcel','project.xls')">导出</a>
    </div>
    <div shiro:hasPermission="pro:transport:list" style="display: inline-block; float: right;">
        队长姓名：<input type="text" id="s_lname" size="30" onkeydown="if(keyCode==13) search()"/>
        司机姓名：<input type="text" id="s_cname" size="30" onkeydown="if(keyCode==13) search()"/>
        车 牌 号：<input type="text" id="s_vidcard" size="30" onkeydown="if(keyCode==13) search()"/>
        <a href="javascript:search();" class="easyui-linkbutton" iconCls="icon-search" plain="true">搜索</a>
    </div>
</div>

<div shiro:hasPermission="pro:transport:list" id="dlg" class="easyui-dialog"
     style="width: 550px;height: 250px;padding: 10px 20px"
     closed="true" buttons="#dlg-buttons" data-options="onClose:function(){resetValue()}">
    <form id="fm" method="post">
        <input type="hidden" id="id" name="id">
        <table cellspacing="8px">
            <h2 style="border-bottom-color: #99cdff">运单信息</h2>
            <div>
                <input class="easyui-combobox"
                       label="队长姓名:"
                       style="width:200px"
                       name="leaderId"
                       data-options="
					url:'/pro/transport/getleader',
					method:'get',
					valueField:'id',
					textField:'lname',
					panelHeight:'auto'">
                <input class="easyui-combobox"
                       label="司机姓名:"
                       style="width:200px"
                       name="driverId"
                       data-options="
					url:'/pro/transport/getdriver',
					method:'get',
					valueField:'id',
					textField:'cname',
					panelHeight:'auto'">
            </div>

            <div>
                <input class="easyui-combobox"
                       label="线路名:"
                       style="width:200px"
                       name="trackId"
                       data-options="
                        url:'/pro/transport/gettrack',
                        method:'get',
                        valueField:'id',
                        textField:'tname',
                        panelHeight:'auto'">
                <input name="vidcard" id="vidcard" class="easyui-textbox" required="true" label="车牌号:"
                       style="width:200px">;
            </div>
            <div>
                <input name="unitPrice" id="unitPrice" class="easyui-textbox" required="true" label="单趟价格:"
                       style="width:200px">;
                <input name="laps" id="laps" class="easyui-textbox" required="true" label="趟&nbsp&nbsp&nbsp数:"
                       style="width:200px">;
            </div>
        </table>
    </form>
</div>

<div id="dlg-buttons">
    <a href="javascript:save('/pro/transport/save','保存成功')" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
    <a href="javascript:closeDialog('#dlg')" class="easyui-linkbutton" iconCls="icon-cancel">关闭</a>
</div>
<script type="text/javascript">
    $(function () {
        $("#dg").datagrid({
            onLoadSuccess: function (data) {
                $('.role-easyui-linkbutton-edit').linkbutton({text: '编辑', plain: true, iconCls: 'icon-edit'});
                $('#dg').datagrid('fixRowHeight');
            }
        });
    })
</script>
</body>
</html>